# 给定的dict, K是姓名,V是年龄,格式如下:
# {'name1':10,'name2':9}
# 返回一个字典, 用来统计最大年龄和最小年龄
# {'max':10,'min':5}
# 提示:
# 遍历字典:  for k,v in dict.items()

import test28max_min_list
def students2(xsh):
    stus=list(xsh.values())
    maxa,mina = test28max_min_list.max_min(stus)
    dxxsh={}
    dxxsh['max']=maxa
    dxxsh['min']=mina
    return dxxsh

def sort_stu(xsh_list):
    new_list=xsh_list.copy()
    new_list.sort(key=lambda x: x['年份'],reverse=True)
    return new_list
def count_gender(stus): # 计算nan/nv人数
    nan=0
    nv=0
    for d in stus:
        if d['性别']=='男':
            nan+=1
        elif d['性别']=='女':
            nv+=1
    return nan,nv

def is_exist_name(xsh,name):  # 判断是否存在此人
    for d in xsh:
        if d['姓名']==name:
            return True
    return False


xsh_list=[{'姓名': '郑钧天', '年份': 2012, '性别': '男', '班级': '3-4', '学号': 26},
{'姓名': '郑钧天2', '年份': 2011, '性别': '男', '班级': '34', '学号': 25},
{'姓名': '高多多', '年份': 2010, '性别': '女', '班级': '34', '学号': 32}]
wxsh={'zjt':10, 'zl':9, 'wbm':11, 'gdd':12, 'wll':10, 'name':8, 'name2':12}
# print(sort_stu(xsh_list))
print(count_gender(xsh_list))
print(is_exist_name(xsh_list,'郑钧'))

    # for k,v in xsh.items():